package com.ztesoft.report.service.impl;

import com.ztesoft.report.constant.DSEnum;
import com.ztesoft.report.dao.SysRoleNewDao;
import com.ztesoft.report.dao.SysUserDao;
import com.ztesoft.report.dao.SysUserMenuDao;
import com.ztesoft.report.dao.SysUserRoleDao;
import com.ztesoft.report.entity.SysRoleNew;
import com.ztesoft.report.entity.SysUser;
import com.ztesoft.report.mutidatasource.annotion.DataSource;
import com.ztesoft.report.service.SysMenuService;
import com.ztesoft.report.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author :xie
 * Email: 1487471733@qq.com
 * Date: 2018/7/24
 * Time: 14:50
 * Describe:
 */
@Service
public class userServiceImpl implements UserService {

    @Autowired
    private SysUserDao sysUserDao;
    @Autowired
    private SysUserMenuDao sysUserMenuDao;
    @Autowired
    private SysUserRoleDao sysUserRoleDao;
    @Autowired
    private SysRoleNewDao sysRoleNewDao;
    @Autowired
    private SysMenuService sysMenuService;

    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public List<SysUser> listUsers() {
        return sysUserDao.selectList(null);
    }

    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public List<SysRoleNew> listSysRole() {
        return sysRoleNewDao.selectList(null);
    }

    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public String getUserPerms(Map<String, Object> map) {
        return sysUserDao.getUserPerms(map);
    }

    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public boolean Permission() {

        //查询 用户
        return false;
    }
    //查询用户的所有权限
    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public List<String> queryAllPerms(String userId) {
        return sysUserDao.queryAllPerms(userId);
    }

    //查询用户的所有菜单ID
    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public List<String> queryAllMenuId(String userId) {
        return sysUserDao.queryAllMenuId(userId);
    }

    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public String getUserpermCode(Map<String, Object> map) {
        return sysUserDao.getUserpermCode(map);
    }

    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public List<String> getListUserPermCode(String userId, String href) {
        return sysUserDao.getListUserPermCode(userId,href);
    }

    @Override
    @DataSource(name= DSEnum.DATA_SOURCE_BIZ)
    public List<String> selectRoleIdByUserId(String userId) {
        return sysUserDao.selectRoleIdByUserId(userId);
    }


}
